﻿namespace Sidvall.Net
{
	public class RangeHeaderValue
	{
		#region Public Members

		public long? From { get; set; }
		public long? To { get; set; }

		#region Copy

		public RangeHeaderValue Copy()
		{
			RangeHeaderValue item;

			item = new RangeHeaderValue()
			{
				From = this.From,
				To = this.To,
			};
			return item;
		}

		#endregion
		#region IsEqual

		public bool IsEqual(RangeHeaderValue obj)
		{
			return IsEqual(this, obj);
		}

		#endregion
		#region IsEqual - Static

		public static bool IsEqual(RangeHeaderValue item1, RangeHeaderValue item2)
		{
			if (item1 == null)
			{
				if (item2 == null)
					return true;
				else
					return false;
			}
			else if (item2 == null)
				return false;
			if (!item1.From.Equals(item2.From))
				return false;
			if (!item1.To.Equals(item2.To))
				return false;
			return true;
		}

		#endregion
		#region ToString

		public override string ToString()
		{
			if (this.From != null)
			{
				if (this.To != null)
					return this.From.ToString() + "-" + this.To.ToString();
				return this.From.ToString() + "-";
			}
			if (this.To != null)
				return "-" + this.To.ToString();
			return string.Empty;
		}

		#endregion

		#endregion
	}
}
